﻿namespace Game {

	class Image {

		field _w; // width
		field _h; // height
		field _0; // native image object

		// width and height, or an image to copy if arg1 is null
		constructor(width_or_img_to_copy, height=null) {
			argmatch(INT, INT) {
				t = @game_image_ctor_size(width_or_img_to_copy, height);
			} else argmatch(INSTANCE:Game.Image) {
				t = @game_image_ctor_copy(width_or_img_to_copy);
			} else argmatch(STRING, NULL) {
				t = @game_image_ctor_file(width_or_img_to_copy);
			} else {
				throw new InvalidArgumentException();
			}

			this._0 = t[0];
			this._w = t[1];
			this._h = t[2];
		}

		property width { get { return this._w; } }
		property height { get { return this._h; } }

		method fill(r, g, b, a=255) {
			@game_image_fill(this._0);
		}
	}
}